﻿using HuiZe.education.Common;
using HuiZe.education.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace HuiZe.education.View
{
    /// <summary>
    /// ForgotPwdView.xaml 的交互逻辑
    /// </summary>
    public partial class OtherLoginView : UserControl
    {
        private Button getValidationCodeBtn;
        public OtherLoginView()
        {
            InitializeComponent();
            Loaded += ForgotPwdView_Loaded;
        }

        private void ForgotPwdView_Loaded(object sender, RoutedEventArgs e)
        {
            if (getValidationCodeBtn == null)
                getValidationCodeBtn = CommonMethods.FindVisualChildItem<Button>(validationCode);
            if (getValidationCodeBtn != null && getValidationCodeBtn.Content.ToString() == "获取验证码")
            {
                LoginViewModel loginViewModel = CommonServiceLocator.ServiceLocator.Current.GetInstance<LoginViewModel>();
                getValidationCodeBtn.Command = loginViewModel.OtherLoginCommand2;
                getValidationCodeBtn.CommandParameter = "3";
            }
          
           

            this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
            {
                this.mobile.Focus();
            }));
        }

        private void mobile_GotFocus(object sender, RoutedEventArgs e)
        {
            LoginViewModel loginViewModel = CommonServiceLocator.ServiceLocator.Current.GetInstance<LoginViewModel>();
            loginViewModel.ErrorMsg.ForgotMobileError = "";
        }

        private void validationCode_GotFocus(object sender, RoutedEventArgs e)
        {
            LoginViewModel loginViewModel = CommonServiceLocator.ServiceLocator.Current.GetInstance<LoginViewModel>();
            loginViewModel.ErrorMsg.ForgotValidationCodeError = "";
        }

        private void pwd_GotFocus(object sender, RoutedEventArgs e)
        {
            LoginViewModel loginViewModel = CommonServiceLocator.ServiceLocator.Current.GetInstance<LoginViewModel>();
            loginViewModel.ErrorMsg.ForgotPwdError = "";
        }

        private void secondPwd_GotFocus(object sender, RoutedEventArgs e)
        {
            LoginViewModel loginViewModel = CommonServiceLocator.ServiceLocator.Current.GetInstance<LoginViewModel>();
            loginViewModel.ErrorMsg.ForgotSecondPwdError = "";
        }
    }
}
